package com.foreknow.elmboot.controller;


import com.foreknow.elmboot.po.Orders;
import com.foreknow.elmboot.service.OrdersService;

import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/OrdersController")
public class OrdersController {

    @Autowired
    private OrdersService orderService;


//    创建订单
    @RequestMapping("/createOrders")
    public Integer CreateOrders(Orders order){

        return orderService.createOrders(order);
    }

//    根据orderId查询订单信息
    @RequestMapping("/getOrdersById")
    public Object getOrdersById(Orders orders){
        Orders ordersById = orderService.getOrdersById(orders.getOrderId());
        return ordersById;

    }

//    根据orderId改变支付状态
    @RequestMapping("/updateorderState")
    public Object updateorderState(Orders orders){
        return orderService.updateorderState(orders.getOrderId());
    }

//    根据userId查询用户所有订单
    @RequestMapping("/listOrdersByUserId")
    public Object listOrdersByUserId(Orders orders){
        return orderService.listOrderByUserId(orders.getUserId());
    }




}
